package com.mrd.shiptask_shipowner.serviecs;


import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

import com.huawei.android.pushagent.PushManager;
import com.mrd.shiptask_shipowner.hwpush.MyApplication;

public class SelfRunningService extends Service {

	@Override
	public IBinder onBind(Intent arg0) {
		return null;
	}

	@Override
	public void onCreate() {
		super.onCreate();
		aboutHuaWerPushAction();
	}

	private void aboutHuaWerPushAction() {
		/**
		 * 定时发送token
		 */
		new Thread(new ThreadShow()).start();
	}

	// 线程类
	class ThreadShow implements Runnable {

		@Override
		public void run() {
			// TODO Auto-generated method stub
			while (true) {
				try {
					// 10秒进行一次检查
					Thread.sleep(10 * 1000);
					// 华为推送模块获取token信息
					MyApplication.instance()
							.setContext(getApplicationContext());
					PushManager.requestToken(getApplicationContext());

				} catch (Exception e) {
				}
			}
		}
	}
}
